from aiogram_dialog import Dialog, Window
from aiogram_dialog.widgets.kbd import Back, Button, Cancel, Next

from src.presentation.tg_bot.dialogs.client.orders.orders_history.handlers import show_user_orders
from src.presentation.tg_bot.dialogs.client.vpn.buy_vpn.handlers import add_order
from src.presentation.tg_bot.dialogs.getters.orders import vpn_router_summary_getter
from src.presentation.tg_bot.dialogs.widgets import LocaleText
from src.presentation.tg_bot.states import VPNRouterSG

vpn_router_info_window = Window(
    LocaleText("vpn-router-info"),
    Next(LocaleText("buy-vpn-router-btn")),
    Cancel(LocaleText("back-btn")),
    state=VPNRouterSG.show_info,
)

create_order_window = Window(
    LocaleText("order-overview"),
    LocaleText("service_type", service_name="{service_name}"),
    LocaleText("order-summ", order_summ="{vpn_summ}$"),
    Button(
        LocaleText("confirm-btn"),
        id="vpn_router_order",
        on_click=add_order,
    ),
    Back(LocaleText("back-btn")),
    Cancel(LocaleText("cancel-btn")),
    state=VPNRouterSG.create_order,
    getter=vpn_router_summary_getter,
)

order_created_window = Window(
    LocaleText("order-created"),
    Button(LocaleText("my-vpns-routers"), id="vpn_router", on_click=show_user_orders),
    Cancel(LocaleText("main-menu-btn")),
    disable_web_page_preview=True,
    state=VPNRouterSG.order_created,
)

vpn_router_dialog = Dialog(vpn_router_info_window, create_order_window, order_created_window)
